package com.example.administrator.yuejian35.Recommend.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.example.administrator.yuejian35.R;
import com.example.administrator.yuejian35.Recommend.adapter.ApplyListAdapter;
import com.example.administrator.yuejian35.Recommend.bean.ShowApplyresult;
import com.example.administrator.yuejian35.Recommend.model.RecommendModel;
import com.example.administrator.yuejian35.base.BaseActivity;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ApplyListActivity extends AppCompatActivity {
    private RecyclerView apply_rv;
    private List<ShowApplyresult> list;
    private String uid;
    private ImageView ic_back;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_apply_list);
        apply_rv= (RecyclerView) findViewById(R.id.apply_rv);
        ic_back= (ImageView) findViewById(R.id.video_pic);

        ic_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        uid= BaseActivity.getUserId();
        //Toast.makeText(ApplyListActivity.this,uid,Toast.LENGTH_LONG).show();
        RecommendModel recommendmodel = new RecommendModel();
        Call call = recommendmodel.showapply(uid);
        call.enqueue(new Callback<List<ShowApplyresult>>() {
            @Override
            public void onResponse(Call<List<ShowApplyresult>> call, Response<List<ShowApplyresult>> response) {
                if(ApplyListActivity.this!=null) {
                    list = response.body();
                    ApplyListAdapter adapter = new ApplyListAdapter(ApplyListActivity.this, list);
                    LinearLayoutManager layoutManager = new LinearLayoutManager(ApplyListActivity.this);
                    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);//Horizontal
                    apply_rv.setLayoutManager(layoutManager);
                    apply_rv.setAdapter(adapter);
                    apply_rv.setItemAnimator(new DefaultItemAnimator());
                }
            }

            @Override
            public void onFailure(Call<List<ShowApplyresult>> call, Throwable t) {

            }
        });
    }
}
